Migrate to v1 methods and types#13728
Merged
dylanjeffers merged 1 commit intomainfrom Feb 19, 2026
Merged
Conversation
|
rickyrombo
approved these changes
Feb 19, 2026
7 tasks
dylanjeffers
added a commit
that referenced
this pull request
May 7, 2026
…4275) ## Summary Track downloads were failing in offline mode — the user-visible symptom is *"clicks download, sees a track attempt, then a failure icon."* This affects **both individual track downloads** (favoriting a track with auto-download on, or any other path that queues a single track) **and tracks inside an album/collection download**, because every track-job entry point lands in the same queue and is processed by the same worker. Two compounding issues in `downloadTrackWorker.ts`, both effectively introduced by the v1 SDK migration (#13728): 1. **`downloadTrackAudio` skipped the v1 pre-signed stream URL.** It built the URL via `sdk.tracks.getTrackStreamUrl()`, ignoring `track.stream.url`. The v1 API returns a pre-signed stream URL (with mirrors) on the track itself; `AudioPlayer` prefers it for online streaming and only falls back to manual URL construction when `stream.url` is missing. The offline worker skipped that working path entirely, so it relied on the fallback for every track. 2. **`downloadTrackCoverArt` was fatal.** It threw when no artwork URI returned 200, and because cover art runs in `all([cover, audio, json])`, a single flaky artwork host failed the entire track download — even though audio is the only essential payload. The collection cover art download follows the opposite (best-effort) pattern; this PR brings the track version in line. Plus `downloadTrackAsync`'s `catch` block silently swallowed the error — no logs, no Sentry breadcrumb. That's why this had been hard to diagnose. ### Why this fixes both individual tracks and collections Every track-job source — `requestDownloadCollectionSaga`, `requestDownloadFavoritedCollectionSaga`, `requestDownloadAllFavoritesSaga`, `watchSaveTrackSaga` (standalone track favorite), `watchAddTrackToPlaylistSaga`, `syncCollectionWorker` — dispatches `addOfflineEntries({ items: [..., { type: 'track' }, ...] })`. The queue processor routes every `type === 'track'` job to a single `downloadTrackWorker`, which calls the two functions patched here. So both flows share the same broken code path. ## Changes - `downloadTrackAudio`: prefer `track.stream.url` (with mirror substitution), keep `getTrackStreamUrl()` + manual signing as a last-resort fallback. Mirrors `AudioPlayer.tsx` logic. - `downloadTrackCoverArt`: best-effort — return silently if all URIs fail rather than throwing. - Extract shared `buildMirrorUris(primary, mirrors)` helper used by both audio and cover art. - Add a `console.warn` in the catch block of `downloadTrackAsync` so future failures are diagnosable instead of silent. ## Test plan - [ ] Offline mode → favorite a single track with "download all favorites" enabled. Track reaches SUCCESS, plays from local file. - [ ] Offline mode → download an album you don't own (where you've favorited it). All tracks reach SUCCESS, audio plays from local file. - [ ] Offline mode → download an album where the artwork host is degraded. Audio still downloads successfully; cover art is best-effort. - [ ] Offline mode → download a single track via the track menu. Still works (no regression). - [ ] Offline mode → toggle "Download all favorites." Track downloads succeed. - [ ] Offline mode → play a downloaded track while offline. File-system playback still works. - [ ] Gated content (USDC / NFT) → confirm the manual-URL fallback path still signs correctly when `stream.url` is unset. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.